import request from "@/utils/request";

export default {
  // 注册
  register(user) {
    return request({
      url: "/user/register",
      method: "post",
      data: user,
    });
  },
  // 获取用户列表
  getUserList(searchModel) {
    return request({
      url: "/user/getUserList",
      method: "get",
      params: {
        username: searchModel.username,
        phoneNumber: searchModel.phoneNumber,
        id: searchModel.id,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
      },
    });
  },

  // 获取用户信息
  getById(id) {
    return request({
      url: `/user/${id}`,
      method: "get",
    });
  },

  // 修改密码
    updatePass(user) {
    return request({
      url: `/user/updatePassword`,
      method: "post",
      data:user
    });
  },

  getInfo(){
    return request({
      url: "/user/info",
      method: "get",
    });
  },

  // 修改头像
  updateAvatar(user) {
    return request({
      url: "/user/updateAv",
      method: "put",
      data:user,
    });
  },

  // 删除
  deleteById(id) {
    return request({
      url: `/user/${id}`,
      method: "delete",
    });
  },
  // 更新
  update(user) {
    return request({
      url: `/user/update`,
      method: "post",
      data: user,
    });
  },

  //update修改密码
  updatePass(user) {
    return request({
      url: `/user/updatePassword`,
      method: "post",
      data:user,
    });
  },

  // 设置用户权限
  setUserRole(userRole) {
    return request({
      url: `/user/setUserRole`,
      method: "post",
      data: userRole,
    });
  },

  // 获取用户角色
  getUserRole(id) {
    return request({
      url: `/user/getUserRole/${id}`,
      method: "get",
    });
  },

  // 获取用户选择器
  getUserOperations() {
    return request({
      url: `/user/getUserOperations`,
      method: "get",
    });
  },
};
